<template>
  <div class="ui-page ui-page__scroll page-activity-detail">
    <div class="activityDetail">
      <div class="activity-detail-image">
        <image class="activity-detail-image--image" :src="activityPic" alt />
      </div>
      <div class="activity-detail-center">
        <div class="title">{{ activityName }}</div>
        <div class="activityDetail-center--extends ui-flex flex--vcenter">
          <div class="time">{{ createTime | date_format('YYYY年MM月DD日 HH:mm') }}</div>
          <div class="activity-detail-center--reader">
            <image class="render-image" src="/static/images/activity/liulan.png" alt />
            <span class="render-txt">{{ readNumber }}</span>
          </div>
        </div>
      </div>
      <div class="content ql-snow">
        <div class="editor-container">
          <uiParse
            :imageProp="{  
              padding: 0,
              lazyLoad: false,
              domain: '' ,
              'max-width': '690rpx', 
              'width': '690rpx'}"
            :content="activityDetail"
          ></uiParse>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { selectActivityById } from "api/order/activities.js";
import uiParse from "@/components/base/parse/index";

import { url } from "@/utils/url.js";

export default {
  name: "activityPageDetail",
  components: { uiParse },
  data() {
    return {
      activityPic: "",
      activityName: "",
      createTime: "",
      readNumber: "",
      activityDetail: ""
    };
  },

  onLoad() {
    const curUrl = url();
    this.activityId = curUrl.query.id || "";
    this.findActivityById(curUrl.query.id);
  },
  methods: {
    findActivityById(activityId) {
      var params = {
        activityId: activityId || this.activityId
      };
      selectActivityById(params).then(({ respCode, respMsg, result }) => {
        if (respCode !== "0") {
          // 加载失败
          this.$toast.fail(respMsg);
          return;
        }
        this.activityPic = result.activityPic;
        this.activityName = result.activityName;
        this.createTime = result.createTime;
        this.readNumber = result.readNumber;
        this.activityDetail = result.activityDetail;
        // 修改标题
        uni.setNavigationBarTitle({
          title: this.activityName || "新闻活动"
        });
      });
    }
  }
};
</script>

<style lang="scss" src="./index.scss"></style>
